// pages/order/order.js
Page({
 
  data: {
    currtab: 0,
    swipertab: [{ name: '全部订单', index: 0 }, { name: '待付款', index: 1 }, { name: '已结束', index: 2 }],
  },
  
  onReady: function () {
    // 页面渲染完成
    this.getDeviceInfo()
    this.orderShow()
  },
 
  getDeviceInfo: function () {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          deviceW: res.windowWidth,
          deviceH: res.windowHeight
        })
      }
    })
  },
 
  /**
  * @Explain：选项卡点击切换
  */
  tabSwitch: function (e) {
    var that = this
    if (this.data.currtab === e.target.dataset.current) {
      return false
    } else {
      that.setData({
        currtab: e.target.dataset.current
      })
    }
  },
 
  tabChange: function (e) {
    this.setData({ currtab: e.detail.current })
    this.orderShow()
  },
 
  orderShow: function () {
    let that = this
    switch (this.data.currtab) {
      case 0:
        that.alreadyShow()
        break
      case 1:
        that.waitPayShow()
        break
      case 2:
        that.lostShow()
        break
    }
  },
  alreadyShow: function(){
    this.setData({
      alreadyOrder: [{ name: "民大超市航北一店", state: "交易成功", time: "2021-11-26 14:22", status: "已结束", url: "https://img1.baidu.com/it/u=1500059949,1604415508&fm=26&fmt=auto", money: "132" }, { name: "民大超市航北一店", state: "交易成功", time: "2021-12-22 18:56", status: "正在配送", url: "https://img1.baidu.com/it/u=1500059949,1604415508&fm=26&fmt=auto", money: "205" }]
    })
  },
 
  waitPayShow:function(){
    this.setData({
      waitPayOrder: [{ name: "民大超市航北一店", state: "待付款", time: "2021-12-14 14:21", status: "未开始", url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fku.90sjimg.com%2Felement_origin_min_pic%2F18%2F01%2F06%2F12549b06ff4ec60f28229cd420dafd59.jpg&refer=http%3A%2F%2Fku.90sjimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1637765963&t=42e54cd47c794619a734eb2cef72aede", money: "186" }],
    })
  },
 
  lostShow: function () {
    this.setData({
      lostOrder: [{ name: "民大超市航北一店", state: "已完成", time: "2021-10-24 10:00", status: "已结束", url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.taopic.com%2Fuploads%2Fallimg%2F120607%2F188923-12060G9213792.jpg&refer=http%3A%2F%2Fimg.taopic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1637765901&t=b712efca2adc625ee510c28442e3f868" ,money:13}],
    })
  },
 
  
})